/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package view.system;

import com.toedter.calendar.JDateChooser;
import java.awt.Component;
import java.awt.KeyboardFocusManager;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.*;
import main.ServicesList;
import model.system.Company;
import org.apache.log4j.Logger;
import view.TransaksiTemplate;

/**
 *
 * @author Yusup Jauhari Shandi <in.visi>
 */
public class CompanyFrm extends TransaksiTemplate {
    private Company company;
    private static Logger log = Logger.getLogger(CompanyFrm.class);
     private Object oldValue, newValue;
    /**
     * Creates new form CompanyFrm
     */
    public CompanyFrm() {
        initComponents();
        initComponentsRules();
        company = new Company();
        jTabbedPane1.remove(1);// pnlPrincipal.setVisible(false);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jToolBar1 = new javax.swing.JToolBar();
        btnSave = new javax.swing.JButton();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        txtNama = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        txtAlamat = new javax.swing.JTextArea();
        jLabel3 = new javax.swing.JLabel();
        txtKota = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        txtPos = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        txtPhone = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        txtFax = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        txtWebsite = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        txtEmail = new javax.swing.JTextField();
        pnlPrincipal = new javax.swing.JPanel();
        txtNpwp = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        txtNpwpName = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        txtNpwpAlamat = new javax.swing.JTextArea();
        jLabel14 = new javax.swing.JLabel();
        txtSKP = new javax.swing.JTextField();
        jLabel15 = new javax.swing.JLabel();
        txtAC = new javax.swing.JTextField();
        txtACName = new javax.swing.JTextField();
        jLabel16 = new javax.swing.JLabel();
        txtBank = new javax.swing.JTextField();
        jLabel17 = new javax.swing.JLabel();
        txtLeadTime = new javax.swing.JTextField();
        jLabel18 = new javax.swing.JLabel();
        txtTOP = new javax.swing.JTextField();
        jLabel19 = new javax.swing.JLabel();
        chkOpenTOP = new javax.swing.JCheckBox();
        chkHold = new javax.swing.JCheckBox();
        jLabel20 = new javax.swing.JLabel();
        cmbJenis = new javax.swing.JComboBox();
        cmbInvoice = new javax.swing.JComboBox();
        jLabel21 = new javax.swing.JLabel();
        jLabel22 = new javax.swing.JLabel();
        cmbKondisi = new javax.swing.JComboBox();
        jLabel23 = new javax.swing.JLabel();
        chKunjungan01 = new javax.swing.JCheckBox();
        chKunjungan02 = new javax.swing.JCheckBox();
        chKunjungan03 = new javax.swing.JCheckBox();
        chKunjungan06 = new javax.swing.JCheckBox();
        chKunjungan05 = new javax.swing.JCheckBox();
        chKunjungan04 = new javax.swing.JCheckBox();
        dtpSKP = new com.toedter.calendar.JDateChooser();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jToolBar1.setFloatable(false);
        jToolBar1.setRollover(true);
        jToolBar1.setSize(this.getWidth(), 50);

        btnSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/filesave.png"))); // NOI18N
        btnSave.setText("Simpan");
        btnSave.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btnSave.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnSave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSaveActionPerformed(evt);
            }
        });
        jToolBar1.add(btnSave);

        jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel2.setText("Nama :");

        txtNama.setText("jTextField1");
        txtNama.setName("txtNama"); // NOI18N

        txtAlamat.setColumns(20);
        txtAlamat.setLineWrap(true);
        txtAlamat.setRows(5);
        txtAlamat.setTabSize(2);
        txtAlamat.setName("txtAlamat"); // NOI18N
        jScrollPane1.setViewportView(txtAlamat);

        jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel3.setText("Alamat :");

        txtKota.setText("jTextField1");
        txtKota.setName("txtKota"); // NOI18N

        jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel4.setText("Kota :");

        jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel5.setText("Kode Pos :");

        txtPos.setText("jTextField1");
        txtPos.setName("txtPos"); // NOI18N

        jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel6.setText("Phone :");

        txtPhone.setText("jTextField1");
        txtPhone.setName("txtPos"); // NOI18N

        jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel7.setText("Fax :");

        txtFax.setText("jTextField1");
        txtFax.setName("txtFax"); // NOI18N

        jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel8.setText("Website :");

        txtWebsite.setText("jTextField1");
        txtWebsite.setName("txtWebsite"); // NOI18N

        jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel9.setText("Email :");

        txtEmail.setText("jTextField1");
        txtEmail.setName("txtEmail"); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel9, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel8, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel7, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel6, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel5, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtNama, javax.swing.GroupLayout.PREFERRED_SIZE, 276, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtPos, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(txtEmail, javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(txtKota, javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(txtPhone, javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(txtFax, javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(txtWebsite, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 276, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(20, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(31, 31, 31)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtNama, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel3)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtKota, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtPos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtPhone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtFax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtWebsite, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel9))
                .addContainerGap(114, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Identitas", jPanel1);

        txtNpwp.setText("jTextField1");
        txtNpwp.setName("txtNpwp"); // NOI18N

        jLabel11.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel11.setText("NPWP :");

        txtNpwpName.setText("jTextField1");
        txtNpwpName.setName("txtNpwpName"); // NOI18N

        jLabel12.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel12.setText("Nama NPWP :");

        jLabel13.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel13.setText("Alamat NPWP :");

        txtNpwpAlamat.setColumns(20);
        txtNpwpAlamat.setLineWrap(true);
        txtNpwpAlamat.setRows(5);
        txtNpwpAlamat.setTabSize(2);
        txtNpwpAlamat.setName("txtNpwpAlamat"); // NOI18N
        jScrollPane2.setViewportView(txtNpwpAlamat);

        jLabel14.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel14.setText("No SKP :");

        txtSKP.setText("jTextField1");
        txtSKP.setName("txtSKP"); // NOI18N

        jLabel15.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel15.setText("No Rekening :");

        txtAC.setText("jTextField1");
        txtAC.setName("txtAC"); // NOI18N

        txtACName.setText("jTextField1");
        txtACName.setName("txtACName"); // NOI18N

        jLabel16.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel16.setText("Giro Atas Nama :");

        txtBank.setText("jTextField1");
        txtBank.setName("txtBank"); // NOI18N

        jLabel17.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel17.setText("Bank :");

        txtLeadTime.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        txtLeadTime.setText("jTextField1");
        txtLeadTime.setName("txtLeadTime"); // NOI18N

        jLabel18.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel18.setText("Lead Time :");

        txtTOP.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        txtTOP.setText("jTextField1");
        txtTOP.setName("txtTOP"); // NOI18N

        jLabel19.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel19.setText("TOP :");

        chkOpenTOP.setText(" : Open TOP");
        chkOpenTOP.setName("chkOpenTOP"); // NOI18N

        chkHold.setText(" : Tahan Pembayaran");
        chkHold.setName("chkHold"); // NOI18N

        jLabel20.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel20.setText("Jenis :");

        cmbJenis.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "PKP", "NON PKP" }));
        cmbJenis.setName("cmbJenis"); // NOI18N

        cmbInvoice.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "SAAT TAGIH", "SAAT KIRIM" }));
        cmbInvoice.setName("cmbInvoice"); // NOI18N

        jLabel21.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel21.setText("Invoice :");

        jLabel22.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel22.setText("Kondisi Barang :");

        cmbKondisi.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "RETUR", "TUKAR GULING", "PUTUS" }));
        cmbKondisi.setName("cmbKondisi"); // NOI18N

        jLabel23.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel23.setText("Kunjungan :");

        chKunjungan01.setText("Senin");
        chKunjungan01.setName("chKunjungan01"); // NOI18N

        chKunjungan02.setText("Selasa");
        chKunjungan02.setName("chKunjungan02"); // NOI18N

        chKunjungan03.setText("Rabu");
        chKunjungan03.setName("chKunjungan03"); // NOI18N

        chKunjungan06.setText("Sabtu");
        chKunjungan06.setName("chKunjungan06"); // NOI18N

        chKunjungan05.setText("Jumat");
        chKunjungan05.setName("chKunjungan05"); // NOI18N

        chKunjungan04.setText("Kamis");
        chKunjungan04.setName("chKunjungan04"); // NOI18N

        dtpSKP.setDateFormatString("d MM yyyy");
        dtpSKP.setName("dtpSKP"); // NOI18N

        javax.swing.GroupLayout pnlPrincipalLayout = new javax.swing.GroupLayout(pnlPrincipal);
        pnlPrincipal.setLayout(pnlPrincipalLayout);
        pnlPrincipalLayout.setHorizontalGroup(
            pnlPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlPrincipalLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel23, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel22, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel19, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel18, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel17, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel16, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel15, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel14, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel13, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel12, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel11, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel20, javax.swing.GroupLayout.Alignment.TRAILING))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(cmbKondisi, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(pnlPrincipalLayout.createSequentialGroup()
                        .addComponent(txtTOP, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(chkOpenTOP))
                    .addGroup(pnlPrincipalLayout.createSequentialGroup()
                        .addComponent(txtLeadTime, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(chkHold))
                    .addGroup(pnlPrincipalLayout.createSequentialGroup()
                        .addGroup(pnlPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(chKunjungan01)
                            .addComponent(chKunjungan04))
                        .addGroup(pnlPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(pnlPrincipalLayout.createSequentialGroup()
                                .addGap(6, 6, 6)
                                .addComponent(chKunjungan02)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(chKunjungan03))
                            .addGroup(pnlPrincipalLayout.createSequentialGroup()
                                .addGap(8, 8, 8)
                                .addComponent(chKunjungan05)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(chKunjungan06))))
                    .addGroup(pnlPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, pnlPrincipalLayout.createSequentialGroup()
                            .addComponent(cmbJenis, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel21)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(cmbInvoice, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addComponent(txtNpwp, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 253, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(txtNpwpName, javax.swing.GroupLayout.PREFERRED_SIZE, 253, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 253, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(pnlPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(txtBank, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 251, Short.MAX_VALUE)
                        .addComponent(txtACName, javax.swing.GroupLayout.Alignment.LEADING))
                    .addGroup(pnlPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, pnlPrincipalLayout.createSequentialGroup()
                            .addComponent(txtSKP, javax.swing.GroupLayout.PREFERRED_SIZE, 141, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(dtpSKP, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addComponent(txtAC, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 251, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(12, Short.MAX_VALUE))
        );
        pnlPrincipalLayout.setVerticalGroup(
            pnlPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlPrincipalLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel20)
                    .addComponent(cmbJenis, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cmbInvoice, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel21))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtNpwp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel11))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtNpwpName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel12))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel13)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(txtSKP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel14))
                    .addComponent(dtpSKP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(7, 7, 7)
                .addGroup(pnlPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtAC, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel15))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtACName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel16))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtBank, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel17))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtLeadTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel18)
                    .addComponent(chkHold))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtTOP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel19)
                    .addComponent(chkOpenTOP))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel22)
                    .addComponent(cmbKondisi, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel23)
                    .addComponent(chKunjungan01)
                    .addComponent(chKunjungan02)
                    .addComponent(chKunjungan03))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(chKunjungan04)
                    .addComponent(chKunjungan05)
                    .addComponent(chKunjungan06))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Principal", pnlPrincipal);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 366, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(42, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 419, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveActionPerformed
        validasi();
    }//GEN-LAST:event_btnSaveActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
        
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new CompanyFrm().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnSave;
    private javax.swing.JCheckBox chKunjungan01;
    private javax.swing.JCheckBox chKunjungan02;
    private javax.swing.JCheckBox chKunjungan03;
    private javax.swing.JCheckBox chKunjungan04;
    private javax.swing.JCheckBox chKunjungan05;
    private javax.swing.JCheckBox chKunjungan06;
    private javax.swing.JCheckBox chkHold;
    private javax.swing.JCheckBox chkOpenTOP;
    private javax.swing.JComboBox cmbInvoice;
    private javax.swing.JComboBox cmbJenis;
    private javax.swing.JComboBox cmbKondisi;
    private com.toedter.calendar.JDateChooser dtpSKP;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JPanel pnlPrincipal;
    private javax.swing.JTextField txtAC;
    private javax.swing.JTextField txtACName;
    private javax.swing.JTextArea txtAlamat;
    private javax.swing.JTextField txtBank;
    private javax.swing.JTextField txtEmail;
    private javax.swing.JTextField txtFax;
    private javax.swing.JTextField txtKota;
    private javax.swing.JTextField txtLeadTime;
    private javax.swing.JTextField txtNama;
    private javax.swing.JTextField txtNpwp;
    private javax.swing.JTextArea txtNpwpAlamat;
    private javax.swing.JTextField txtNpwpName;
    private javax.swing.JTextField txtPhone;
    private javax.swing.JTextField txtPos;
    private javax.swing.JTextField txtSKP;
    private javax.swing.JTextField txtTOP;
    private javax.swing.JTextField txtWebsite;
    // End of variables declaration//GEN-END:variables

    @Override
    public void execute(boolean withVisible, int id) {
          initForm();
          
          loadData();
         if (withVisible) { setVisible(true); }
    }

    @Override
    protected void initForm() {
        txtNama.setText("");
        txtAC.setText("");
        txtACName.setText("");
        txtAlamat.setText("");
        txtBank.setText("");
        txtEmail.setText("");
        txtFax.setText("");
        txtKota.setText("");
        txtLeadTime.setText("0");
        txtNpwp.setText("");
        txtNpwpAlamat.setText("");
        txtNpwpName.setText("");
        txtPhone.setText("");
        txtPos.setText("");
        txtSKP.setText("");
        txtTOP.setText("0");
        txtWebsite.setText("");
    }

    @Override
    protected void initGrid() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    protected void loadData() {
       company = ServicesList.getCompanyService().getCompany();
       txtNama.setText(company.getCompanyName());
       txtAlamat.setText(company.getAddressLine1());
       txtKota.setText(company.getCity());
       txtPos.setText(company.getPostCode());
       txtPhone.setText(company.getPhone());
       txtFax.setText(company.getFax());
       txtEmail.setText(company.getEmail());
       txtWebsite.setText(company.getWebsite());
               
    }

    @Override
    protected void saveData() {
        company.setCompanyId(1);
        company.setCompanyName(txtNama.getText());
        company.setAddressLine1(txtAlamat.getText());
        company.setCity(txtKota.getText());
        company.setPostCode(txtPos.getText());
        company.setPhone(txtPhone.getText());
        company.setFax(txtFax.getText());
        company.setEmail(txtEmail.getText());
        company.setWebsite(txtWebsite.getText());
        company.setWebsite(txtWebsite.getText());
        boolean saved = false;
        try{
            saved = ServicesList.getCompanyService().save(company);
            
        } catch(Exception ex){
            log.error(ex);
            JOptionPane.showMessageDialog(this, "Data gagal disimpan!"
            ,"Error",JOptionPane.ERROR_MESSAGE);
        }
        
        initButtonState(!saved);
    }

    @Override
    protected void validasi() {
        boolean valid;
        
        valid = txtNama.getText().equals("") ? false:true;
        if (!valid) {
            JOptionPane.showMessageDialog(this, "Nama belum diisi.!"
            ,"Warning",JOptionPane.WARNING_MESSAGE);}
        
        if (valid) { saveData(); }
    }

    @Override
    protected void posting() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    protected void initButtonState(boolean state) {
        btnSave.setEnabled(state);
    }
    
    public void moveNext() {
        KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
        manager.focusNextComponent();
    }
    

    @Override
    protected void initComponentsRules() {
        btnSave.registerKeyboardAction(btnSave.getActionForKeyStroke(
            KeyStroke.getKeyStroke(KeyEvent .VK_SPACE, 0, false)), KeyStroke.getKeyStroke(KeyEvent .VK_ENTER, 0, false), JComponent.WHEN_FOCUSED);
 
        btnSave.registerKeyboardAction(btnSave.getActionForKeyStroke(
            KeyStroke.getKeyStroke(KeyEvent .VK_SPACE, 0, true)), KeyStroke.getKeyStroke(KeyEvent .VK_ENTER, 0, true), JComponent.WHEN_FOCUSED);
        
        txtAC.addKeyListener(new view.system.CompanyFrm.ActionKeyListener());
        txtAC.addFocusListener(new view.system.CompanyFrm.ActionFocusGained());
        txtACName.addKeyListener(new view.system.CompanyFrm.ActionKeyListener());
        txtACName.addFocusListener(new view.system.CompanyFrm.ActionFocusGained());
        txtBank.addKeyListener(new view.system.CompanyFrm.ActionKeyListener());
        txtBank.addFocusListener(new view.system.CompanyFrm.ActionFocusGained());
        txtEmail.addKeyListener(new view.system.CompanyFrm.ActionKeyListener());
        txtEmail.addFocusListener(new view.system.CompanyFrm.ActionFocusGained());
        txtFax.addKeyListener(new view.system.CompanyFrm.ActionKeyListener());
        txtFax.addFocusListener(new view.system.CompanyFrm.ActionFocusGained());
        txtKota.addKeyListener(new view.system.CompanyFrm.ActionKeyListener());
        txtKota.addFocusListener(new view.system.CompanyFrm.ActionFocusGained());
        txtLeadTime.addKeyListener(new view.system.CompanyFrm.ActionKeyListener());
        txtLeadTime.addFocusListener(new view.system.CompanyFrm.ActionFocusGained());
        txtNama.addKeyListener(new view.system.CompanyFrm.ActionKeyListener());
        txtNama.addFocusListener(new view.system.CompanyFrm.ActionFocusGained());
        txtNpwp.addKeyListener(new view.system.CompanyFrm.ActionKeyListener());
        txtNpwp.addFocusListener(new view.system.CompanyFrm.ActionFocusGained());
        txtNpwpName.addKeyListener(new view.system.CompanyFrm.ActionKeyListener());
        txtNpwpName.addFocusListener(new view.system.CompanyFrm.ActionFocusGained());
        txtPhone.addKeyListener(new view.system.CompanyFrm.ActionKeyListener());
        txtPhone.addFocusListener(new view.system.CompanyFrm.ActionFocusGained());
        txtPos.addKeyListener(new view.system.CompanyFrm.ActionKeyListener());
        txtPos.addFocusListener(new view.system.CompanyFrm.ActionFocusGained());
        txtSKP.addKeyListener(new view.system.CompanyFrm.ActionKeyListener());
        txtSKP.addFocusListener(new view.system.CompanyFrm.ActionFocusGained());
        txtWebsite.addKeyListener(new view.system.CompanyFrm.ActionKeyListener());
        txtWebsite.addFocusListener(new view.system.CompanyFrm.ActionFocusGained());
        txtTOP.addKeyListener(new view.system.CompanyFrm.ActionKeyListener());
        txtTOP.addFocusListener(new view.system.CompanyFrm.ActionFocusGained());
        txtNpwpAlamat.addKeyListener(new view.system.CompanyFrm.ActionKeyListener());
        txtAlamat.addKeyListener(new view.system.CompanyFrm.ActionKeyListener());
        dtpSKP.addKeyListener(new view.system.CompanyFrm.ActionKeyListener());
        cmbInvoice.addKeyListener(new view.system.CompanyFrm.ActionKeyListener());
        cmbJenis.addKeyListener(new view.system.CompanyFrm.ActionKeyListener());
        cmbKondisi.addKeyListener(new view.system.CompanyFrm.ActionKeyListener());
        chKunjungan01.addKeyListener(new view.system.CompanyFrm.ActionKeyListener());
        chKunjungan02.addKeyListener(new view.system.CompanyFrm.ActionKeyListener());
        chKunjungan03.addKeyListener(new view.system.CompanyFrm.ActionKeyListener());
        chKunjungan04.addKeyListener(new view.system.CompanyFrm.ActionKeyListener());
        chKunjungan05.addKeyListener(new view.system.CompanyFrm.ActionKeyListener());
        chKunjungan06.addKeyListener(new view.system.CompanyFrm.ActionKeyListener());
        chkHold.addKeyListener(new view.system.CompanyFrm.ActionKeyListener());
        chkOpenTOP.addKeyListener(new view.system.CompanyFrm.ActionKeyListener());
    }
    
    
    class ActionKeyListener implements KeyListener {
        @Override public void keyTyped(KeyEvent e) {} 
        @Override public void keyReleased(KeyEvent e) {}
        
        @Override public void keyPressed(KeyEvent e) {
            switch (e.getKeyCode()) { 
                case KeyEvent.VK_TAB: 
                    switch (e.getComponent().getName()) {
                        case "txtAlamat": moveNext();break;
                        case "txtNpwpAlamat": moveNext();break;
                    }
                                        
                    break; 
                case KeyEvent.VK_ENTER: moveNext(); break; 
            }
        }
    }
    
    class ActionFocusGained implements FocusListener {
        @Override public void focusGained(FocusEvent e) { 
            Component componen = (Component) e.getSource(); 
            if (componen instanceof JTextField) { oldValue = ((JTextField) componen).getText();
            }else if (componen instanceof JComboBox) { oldValue = ((JComboBox) componen).getSelectedIndex();
            }else if (componen instanceof JCheckBox) { oldValue = ((JCheckBox) componen).isSelected();
            }else if (componen instanceof JTextArea) { oldValue = ((JTextArea) componen).getText();
            }else if (componen instanceof JDateChooser) { oldValue = ((JDateChooser) componen).getDate(); }
        }
        
        @Override public void focusLost(FocusEvent e) {
            Component componen = (Component) e.getSource(); 
            if (componen instanceof JTextField) { newValue = ((JTextField) componen).getText();
            }else if (componen instanceof JComboBox) { newValue = ((JComboBox) componen).getSelectedIndex();
            }else if (componen instanceof JCheckBox) { newValue = ((JCheckBox) componen).isSelected();
            }else if (componen instanceof JTextArea) { newValue = ((JTextArea) componen).getText();
            }else if (componen instanceof JDateChooser) { newValue = ((JDateChooser) componen).getDate(); }
            if (!newValue.equals(oldValue)) { initButtonState(true); }
        }
    }
}
